﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml" />
        <ResourceDictionary Source="../Converters.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="{x:Type ComboBox}" TargetType="ComboBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid MinHeight="32">
                        <Rectangle Fill="White" Visibility="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}" />
                        <Border BorderBrush="Gray"
								Background="#FFF3F3F3"
                                BorderThickness="0"
                                SnapsToDevicePixels="True" />
                        <Rectangle Height="1"
                                   VerticalAlignment="Bottom"
                                   Fill="Gray"
								   Opacity="0"
                                   Visibility="{Binding IsDropDownOpen,
                                                        RelativeSource={RelativeSource TemplatedParent},
                                                        Converter={StaticResource BooleanToVisibilityInverseConverter}}" />
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="32" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Margin="6,3"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding SelectionBoxItem}"
                                              ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                              IsHitTestVisible="False" />
                            <ToggleButton Grid.ColumnSpan="2"
                                          ClickMode="Press"
                                          Focusable="False"
                                          IsChecked="{Binding Path=IsDropDownOpen,
                                                              Mode=TwoWay,
                                                              RelativeSource={RelativeSource TemplatedParent}}">
                                <ToggleButton.Style>
                                    <Style TargetType="ToggleButton">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="ToggleButton">
                                                    <Grid>
                                                        <Grid Background="White" Opacity="0" />
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition />
                                                                <ColumnDefinition Width="32" />
                                                            </Grid.ColumnDefinitions>

                                                            <Grid Grid.Column="1">
                                                                <Grid MinWidth="24"
                                                                      MinHeight="24"
                                                                      Visibility="Visible">
                                                                    <Rectangle Margin="0" Visibility="Visible" Fill="White" Opacity="0" />
                                                                </Grid>
                                                                <Path Width="12"
                                                                      Height="12"
                                                                      Margin="0,0,0,0"
                                                                      Data="F1M753.644,-13.0589L753.736,-12.9639 753.557,-12.7816 732.137,8.63641 732.137,29.7119 756.445,5.40851 764.094,-2.24384 764.275,-2.42352 771.834,5.1286 796.137,29.4372 796.137,8.36163 774.722,-13.0589 764.181,-23.5967 753.644,-13.0589z"
                                                                      Fill="{DynamicResource color_blue}"
                                                                      RenderTransformOrigin="0.5,0.5"
																	   Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"
                                                                      Stretch="Uniform">
                                                                    <Path.RenderTransform>
                                                                        <TransformGroup>
                                                                            <TransformGroup.Children>
                                                                                <RotateTransform Angle="0" />
                                                                                <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                            </TransformGroup.Children>
                                                                        </TransformGroup>
                                                                    </Path.RenderTransform>
                                                                </Path>
                                                                <Path Width="12"
                                                                      Height="12"
                                                                      Margin="0,0,0,0"
                                                                      Data="F1M181.297,177.841L181.205,177.746 181.385,177.563 202.804,156.146 202.804,135.07 178.497,159.373 170.847,167.026 170.666,167.205 163.107,159.653 138.804,135.345 138.804,156.42 160.219,177.841 170.76,188.379 181.297,177.841z"
                                                                      Fill="{DynamicResource color_blue}"
                                                                      RenderTransformOrigin="0.5,0.5"
																	   Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityInverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
                                                                      Stretch="Uniform">
                                                                    <Path.RenderTransform>
                                                                        <TransformGroup>
                                                                            <TransformGroup.Children>
                                                                                <RotateTransform Angle="0" />
                                                                                <ScaleTransform ScaleX="1" ScaleY="1" />
                                                                            </TransformGroup.Children>
                                                                        </TransformGroup>
                                                                    </Path.RenderTransform>
                                                                </Path>
                                                            </Grid>
                                                        </Grid>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ToggleButton.Style>
                            </ToggleButton>
                        </Grid>

                        <Popup AllowsTransparency="True"
                               Focusable="False"
                               IsOpen="{TemplateBinding IsDropDownOpen}"
                               PopupAnimation="Slide">
                            <Grid MinWidth="{TemplateBinding ActualWidth}"
                                  MaxHeight="{TemplateBinding MaxDropDownHeight}"
                                  Background="White">
                                <Border BorderBrush="#FFF3F3F3" BorderThickness="1,0,1,1">
                                    <ScrollViewer Background="Transparent">
                                        <StackPanel Background="Transparent"
                                                    IsItemsHost="True"
                                                    KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Border>
                            </Grid>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>